Skip to content

fix: fail closed on IBKR execution readiness - #358

Merged
Pigbibi merged 4 commits into
mainfrom
agent/ibkr-runtime-readiness
Jul 28, 2026
Merged

fix: fail closed on IBKR execution readiness#358
Pigbibi merged 4 commits into
mainfrom
agent/ibkr-runtime-readiness

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Verify live IBKR order-write access with an IBKR what-if order before execution; the probe cannot execute as a live order.
  • Fail closed when the selected cash-only account snapshot lacks an explicit market-currency cash balance, and recognize IBKR ledger cash tags without treating AvailableFunds as cash.
  • Propagate rejected submissions as a blocked execution result through runtime reports and heartbeat validation.
  • Treat pre-market timestamps outside the returned calendar schedule as market-closed so an explicit force-run can proceed safely.

Root cause

The runtime could prove API connectivity but not writable order access. It could also receive valid IBKR account data using $LEDGER-* cash tags while resolving cash to zero, and rejected submissions could be reported as a successful/no-op cycle. Separately, the market calendar raised before the force-run override was evaluated during pre-market verification.

Behavior and safety

  • The permission probe uses IBKR whatIfOrder; IBKR evaluates commission and margin but does not place the order.
  • Cash-only execution remains fail-closed whenever a supported market-currency cash balance is absent, including when positions exist.
  • A fully rejected submission becomes execution_status=blocked; runtime reports and heartbeat checks reject it, except for the existing expected safety guards.
  • The HTTP response remains 200 for a blocked cycle to avoid automatic Scheduler retries, while the durable runtime report is marked as an error.
  • Transient connection failures during the permission probe retain the existing retry behavior.

Validation

  • Related tests: 103 passed
  • Ruff on affected Python files: passed
  • Python bytecode compilation for affected runtime modules: passed
  • git diff --check: passed

The repository-wide suite was not rerun after the final review fixes; prior full-suite runs contained known baseline failures outside this patch. The affected test set above was rerun from the final commit state.

Live verification scope

An earlier pre-review revision was manually deployed to the single authorized live target. /health and dry-run returned 200. One authorized live run returned 200 and submitted one DAY limit order with status Submitted; no read-only/API-321 failure was observed. This confirms submission, not fill.

The current head, including the what-if permission probe and subsequent Codex review fixes, has not been redeployed. Its evidence is the local validation and PR checks above; the normal deployment pipeline can replace the manual deployment after merge.

Co-Authored-By: Codex <noreply@openai.com>
@Pigbibi
Pigbibi marked this pull request as ready for review July 28, 2026 10:55

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10e368477b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread application/execution_service.py Outdated
Comment thread main.py Outdated

Pigbibi commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

Co-Authored-By: Codex <noreply@openai.com>

Pigbibi commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa01c79152

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread application/runtime_broker_adapters.py
Co-Authored-By: Codex <noreply@openai.com>

Pigbibi commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3af2c31ed3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread application/runtime_broker_adapters.py Outdated
Comment thread application/ibkr_portfolio.py Outdated
Co-Authored-By: Codex <noreply@openai.com>
@Pigbibi

Pigbibi commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 3ee8b74bbe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Pigbibi
Pigbibi merged commit af6ff62 into main Jul 28, 2026
12 checks passed
@Pigbibi
Pigbibi deleted the agent/ibkr-runtime-readiness branch July 28, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant